<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>活动页</title>
    <link rel="stylesheet" href="styles/base.css">
    <link rel="stylesheet" href="styles/common.css">
    <link rel="stylesheet" href="styles/applyfor.css">
</head>
<body>
    <header id="header" class="flex justify-content-between align-items-center">
    	<div class="back"><span>返回活动</span></div>
        <span class="title_name">我的佣金</span>
        <div class="erwm QRCode" id='QRCode' data-num='2' >课代表二维码</div>
    </header>
    <!--二维码弹窗-->
    <div class="fixed_show fixed_show2">
        <div class="schoolshow">
            <div class="schoolcont1" style="height: auto">
                <img class="close1 closePop" src="images/close1.png" alt="">
                <div class="erbg">
                    <img src="" class="QRCode-img"/>
                </div>
            </div>
        </div>
    </div>
    <!--二维码弹窗-->
    <div class="myrebate">
    	<div class="myrebadiv flex">
    		<div class="myflex bor_right">
    			<p>我的累计金额</p>
    			<p>￥0.00</p>
    		</div>
    		<div class="myflex">
    			<p>我的佣金记录</p>
    			<p>0笔</p>
    		</div>
    	</div>
    </div>
	<div class="tabNav">
        <div class="tab flex">
            <div class="tabdiv item tabactive">我的佣金记录(<span id="ynum">0</span>)</div>
            <div class="tabdiv item">我的课代表(<span id="knum">0</span>)</div>
        </div>
    </div>
	<div class="content">
        <div class="lists lists1">
            <div class="content3" id="content"></div>
            <script type="text/html" id="test">
                {{if data.length>0}}
                   {{each data as value index}}
                    <a class="item opacity flex align-items-center justify-content-between" href="'+data[i].link+'">
                    	<img class="list_img" src="{{value.headimgurl}}"/>
                        <h3 class="username">{{value.nickname}}</h3>
                        <span class="date list1">{{if value.type == "1"}}直接购买{{else}}转介绍{{/if}}</span>
                        <span class="number list1">+{{value.commission}}</span>
                    </a>
                    {{/each}}
                {{/if}}
            </script>
         </div>
		<div class="lists lists2" style="display: none;">
            <div class="content3" id="content2"></div>
            <script type="text/html" id="test2">
                {{if data.length>0}}
                    {{each data as value index}}
                    <a class="item opacity flex align-items-center justify-content-between" href="'+data[i].link+'">
                        <img class="list_img" src="{{value.headimgurl}}"/>
                        <h3 class="username">{{value.nickname}}</h3>
                        {{if value.register_flag == 0}}
                        <span style="background:rgba(255, 141, 26, 1);" class="list2 span1">老生</span>
                        {{else if value.register_flag == 1}}
                        <span style="background:rgba(67, 207, 124, 1);" class="list2 span1">新生</span>
                        {{/if}}
                        <span class="number list2">{{value.mobile}}</span>
                        {{if value.status==1}}
                        <span style="background:rgba(42, 130, 228, 1);"class="list2 span2">设置课代表</span>
                        {{else if value.status==0}}
                        <span style="background:rgba(212, 48, 48, 1);"class="list2 span2">取消课代表</span>
                        {{/if}}
                    </a>
                    {{/each}}
                {{/if}}
            </script>
		</div>
	</div>
<script type="text/javascript" src="js/zepto.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
    <script src="js/template-web.js"></script>
<script>
    changePx(); //改变根元素的px
    var getSearchObj = getSerch(location.search);
    getBaseInfor();
    $(function(){
        if(getSearchObj.hasPersonalCenter==1){
            $('.QRCode').css('visibility','visible');
            $('.tabNav').show();
		
        }else{
			$('.content').css('height','calc(100% - 2.9rem)')
		}
        $('.tab .item').on('click',function() {
            var $this = $(this);
            itemIndex = $this.index();
            $this.addClass('tabactive').siblings('.item').removeClass('tabactive');
            $('.lists').eq(itemIndex).show().siblings('.lists').hide();
        });
        //关闭弹窗
        $(".closePop").click(function(){
            $("body").css("overflow","auto");
            $(".fixed_show").hide();
        })
	});
    function getBaseInfor(){
        //我的佣金
        $.ajax({
            type: "get",
            contentType: "application/json;charset=UTF-8",
            url: 'http://api.ucmd.cn/renren-api/act/activitycommission/list/'+getSearchObj.openId,
            success: function(result) {
                if(result.code==0){
                    var data = result;
                    $("#ynum").text(data.data.length)
                    var html=template('test',data);
                    document.getElementById('content').innerHTML = html;
                }else{
                    swal({
                        title: data.msg,
                        icon: "warning",
                        button: "确认",
                        dangerMode: true
                    })
                }
            }
        });
        //我的课代表
        $.ajax({
            type: "get",
            contentType: "application/json;charset=UTF-8",
            url:'http://api.ucmd.cn/renren-api/act/activityagent/myAgent/olt6juC7zeRd0PLT2d3BAjcHmxBI',
            success: function(result) {
                if(result.code==0){
                    var data = result;
                    $("#knum").text(data.data.length)
                    var html=template('test2',data);
                    document.getElementById('content2').innerHTML = html;
                }else{
                    swal({
                        title: data.msg,
                        icon: "warning",
                        button: "确认",
                        dangerMode: true
                    })
                }

            }
        });
    }
</script>
</body>
</html>